<%--
  Created by IntelliJ IDEA.
  User: LWLONG
  Date: 2021/2/28
  Time: 19:39
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- 在web项目中 css的路径要替换为 css文件的uri
    也就是 /项目名/css/style.css
    -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
</head>
<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader">

            </div>
            <div id="topheader">
                <h1 id="title">
                    <a href="${pageContext.request.contextPath}/product/queryList">商品管理</a>
                </h1>
            </div>
            <div id="navigation">
            </div>
        </div>
        <div id="content">
            <p id="whereami">

            </p>
            <h1>
                欢迎,${username}!
            </h1>
            <h5>&nbsp;</h5>
            <form  method="post" action="${pageContext.request.contextPath}/product/queryList" >
                商品名:<input name="productName" value="${productName}"/>
                价格：<select name="operation">
                <option value="0">操作</option>
                <option <c:if test="${operation == '>'}">selected = "selected"</c:if> value=">">></option>
                <option <c:if test="${operation == '<'}">selected = "selected"</c:if> value="<"><</option>
            </select>
                <input type="number" name="price"  value="${price}"/>
                <input type="submit" value="搜索"/>
            </form>
            <h5 style="height: 2px;">&nbsp;</h5>
            <h4 style="color: #CE090E">${msg}</h4>
            <c:remove var="msg" scope="session"></c:remove>
            <div align="right"><a class="btn" href="${pageContext.request.contextPath}/cart/cartList.jsp">购物车管理</a></div>
            <form action="${pageContext.request.contextPath}/product/deleteChecked" method="post">
                <table class="table">
                    <tr class="table_header">
                        <td>
                            <input type="submit" value="删除选中" />
                        </td>
                        <td>
                            商品名
                        </td>
                        <td>
                            单价
                        </td>
                        <td>库存</td>
                        <td>状态</td>
                        <td>
                            商品描述
                        </td>
                        <td>
                            操作
                        </td>
                    </tr>
                    <c:forEach var="product" items="${products}">
                        <tr class="row1">
                            <td>
                                <input type="checkbox" name="id"  value="${product.id}" />
                            </td>
                            <td>
                                    ${product.name}
                            </td>
                            <td>
                                ￥${product.price}
                            </td>
                            <td>${product.account}</td>

                            <c:if test="${product.status == 0}"> <td>上架</td></c:if>
                            <c:if test="${product.status == 1}"> <td>下架</td></c:if>
                            <td>
                                    ${product.description}
                            </td>
                            <td>
                                <a href="${pageContext.request.contextPath}/product/delete/${product.id}">删除</a>&nbsp;<a href="${pageContext.request.contextPath}/product/getOneProduct/${product.id}">修改</a> <a href="${pageContext.request.contextPath}/cart/addCart/${product.id}">添加购物车</a>
                            </td>
                        </tr>

                    </c:forEach>
                </table>
            </form>
            <p>
                <a href="${pageContext.request.contextPath}/product/addOrUpdate?type=add" class="button">添加商品</a>
            </p>
        </div>
        <div class="text-center">
            <nav>
                <ul class="pagination">

                    <li>  <c:if test="${page.hasPrevious}"> <a href="${pageContext.request.contextPath}/product/queryList?pageNum=1&pageSize=3&productName=${productName}&operation=${operation}&price=${price}" class="button">首页</a> </li>

                    <li>   <a href="${pageContext.request.contextPath}/product/queryList?pageNum=${page.prePage}&pageSize=3&productName=${productName}&operation=${operation}&price=${price}">上一页</a> </li>

                    </c:if>

                    <c:forEach var="i" begin="${page.begin}" end="${page.end}">
                        <li>  <a href="${pageContext.request.contextPath}/product/queryList?pageNum=${i}&pageSize=3&productName=${productName}&operation=${operation}&price=${price}" class="button">${i}</a> </li>
                    </c:forEach>

                    <c:if test="${page.hasNext}">
                    <li>    <a href="${pageContext.request.contextPath}/product/queryList?pageNum=${page.nextPage}&pageSize=3&productName=${productName}&operation=${operation}&price=${price}">下一页</a> </li>
                    <li>   <a href="${pageContext.request.contextPath}/product/queryList?pageNum=${page.totlePages}&pageSize=3&&productName=${productName}&operation=${operation}&price=${price}" class="button">尾页</a> </c:if> </li>

                </ul>
            </nav>
        </div>

        <hr>



    </div>
    <div id="footer">
        <div id="footer_bg">
            www.zparkhr.com.cn
        </div>
    </div>
</div>
</body>
</html>
